package com.nulldev.util.web.URLUtils.internal.testing;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Iterator;

import com.nulldev.util.JVM.JVM;
import com.nulldev.util.data.Arrays.misc.RoundRobin;
import com.nulldev.util.data.Charsets.CharsetUtil;
import com.nulldev.util.internal.backport.concurrency9.Lists;

public class URLDecEncTesting {

	public static void main(String[] args) {
		final String o = "https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1615005708/ei/rLNCYIOMLrGKs8IPuIKG2AI/ip/0.0.0.0/id/5qap5aO4i9A.0/itag/91/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/sgoap/gir%3Dyes%3Bitag%3D139/sgovp/gir%3Dyes%3Bitag%3D160/hls_chunk_host/r2---sn-f5f7ln7y.googlevideo.com/playlist_duration/30/manifest_duration/30/vprv/1/playlist_type/DVR/initcwndbps/5040/mh/30/mm/44/mn/sn-f5f7ln7y/ms/lva/mv/m/mvi/2/pl/19/dover/11/keepalive/yes/fexp/24007246/mt/1614983779/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,sgoap,sgovp,playlist_duration,manifest_duration,vprv,playlist_type/sig/AOq0QJ8wRAIgWGdXV2DKncg9oMTxPgDG5cdBrVbGaQi9UithtgJ_JvUCIGUIqG21F27SegOk-cm9Tr1fD5GPPc-zx2WMyYUS8-TS/lsparams/hls_chunk_host,initcwndbps,mh,mm,mn,ms,mv,mvi,pl/lsig/AG3C_xAwRQIhAO1t57WG0PvjiEeAYC6f3atLQU0LHdEGYbbkVJWXKxlhAiArzMnz0oqV0a9bMzLLwsW0vCHA72Ii0dhJngYHMgzlyA%3D%3D/playlist/index.m3u8";
		{
			final long s = System.currentTimeMillis();
			final String r;
			try {
				r = URLEncoder.encode(o, CharsetUtil.UTF_8.name());
			} catch (UnsupportedEncodingException e1) {
				throw new RuntimeException(e1);
			}
			final long e = System.currentTimeMillis();
			JVM.println("JRE URLEncoder:encode: " + (e - s) + " ms");
			JVM.println(r);
		}
		{
			final com.nulldev.util.codecs.data.impl.URLEncoder ue = new com.nulldev.util.codecs.data.impl.URLEncoder();
			final long s = System.currentTimeMillis();
			final String r;
			try {
				r = ue.encodeToString(o.getBytes(CharsetUtil.UTF_8));
			} catch (Exception e1) {
				throw new RuntimeException(e1);
			}
			final long e = System.currentTimeMillis();
			JVM.println("ZIE URLEncoder:encode: " + (e - s) + " ms");
			JVM.println(r);
		}
		{
			final Iterator<com.nulldev.util.codecs.data.impl.URLEncoder> DECODER_SESSIONS = new RoundRobin<com.nulldev.util.codecs.data.impl.URLEncoder>(
					Lists.of(new com.nulldev.util.codecs.data.impl.URLEncoder(), new com.nulldev.util.codecs.data.impl.URLEncoder(),
							new com.nulldev.util.codecs.data.impl.URLEncoder(), new com.nulldev.util.codecs.data.impl.URLEncoder()))
					.iterator();
			final long s = System.currentTimeMillis();
			final String r;
			try {
				r = DECODER_SESSIONS.next().encodeToString(o.getBytes(CharsetUtil.UTF_8));
			} catch (Exception e1) {
				throw new RuntimeException(e1);
			}
			final long e = System.currentTimeMillis();
			JVM.println("ZIE_RR URLEncoder:encode: " + (e - s) + " ms");
			JVM.println(r);
		}
	}

}
